const {
	reqGet,
	reqPost,
} = require('@utils/request')
const {
	$U_UserInfo,
	$U_SetItem,
	$U_GetItem,
} = require('@utils/storage')

module.exports = {
	submitMethod() {
		let {
			bugDialog,
			bugText,
			alertDialog,
			alertText,
			store,
		} = this
		let userInfo = $U_UserInfo()
		reqPost('/ult/bug/submit', {
			user_id: userInfo.id,
			project_version: store.version,
			project_id: store.projectId,
			description: bugText.textbox('getValue')
		}).then(result => {
			if (result && result.insertId > 0) {
				alert('提交成功！')
				bugDialog.dialog('close')
				return false
			}
			alertText.textbox('setValue', JSON.stringify(result, null, 5))
			alertDialog.dialog('open')
		})
	},
}